<?php
// +----------------------------------------------------------------------
// | HkCms
// +----------------------------------------------------------------------
// | Copyright (c) 2012-2019 http://www.hkcms.cn, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 广州恒企教育科技有限公司 <admin@hkcms.cn>
// +----------------------------------------------------------------------

namespace app\content\validate;

use think\Validate;

class Content extends Validate
{
    protected $rule = [
        'catid' => 'require|isUltimate',
        'title' => 'require',
    ];

    protected $message  =   [
        'catid.require' => '请选择栏目！',
        'catid.isUltimate' => '该模型非终极栏目，无法添加信息！',
        'title.require' => '标题必须填写！',
       
    ];

    /**
     * 是否终极栏目
     * @param type $catid
     * @return boolean
     */
    protected function isUltimate($catid) {
        if (getCategory($catid, 'child')) {
            return false;
        } else {
            return true;
        }
    }


}
// <!-- array('catid', 'require', '请选择栏目！', 1, 'regex', 1),
// array('catid', 'isUltimate', '该模型非终极栏目，无法添加信息！', 1, 'callback', 1),
// //标题
// array('title', 'require', '标题必须填写！', 1, 'regex', 1), -->